package com.sz.common.pay.pingan.util;

import com.sz.common.pay.pingan.constant.ResponseCode;
import com.sz.common.pay.pingan.entity.common.CommonHeadResponse;
import com.sz.common.pay.pingan.exception.PayCommonException;

/**
 * Function: 支付SERVER异常处理 <br>
 *
 * @author: siqishangshu <br>
 * @date: 2017-12-20 09:13:00
 */
public class PayExceptionUtil {


    public static void throwPayCommonException(String message, ResponseCode responseCode) throws PayCommonException {
        PayCommonException payCommonException = new PayCommonException(message);
        payCommonException.getErrorMessage().setRspCode(responseCode.getCode());
        payCommonException.getErrorMessage().setRspMsg(responseCode.getMessage());
        throw payCommonException;
    }

    public static void throwPayCommonException(String sequence,String message, ResponseCode responseCode) throws PayCommonException {
        PayCommonException payCommonException = new PayCommonException(message);
        payCommonException.getErrorMessage().setRspCode(responseCode.getCode());
        payCommonException.getErrorMessage().setRspMsg(responseCode.getMessage());
        payCommonException.getErrorMessage().setThirdLogNo(sequence);
        throw payCommonException;
    }
    public static void throwPayCommonException(String sequence,String message) throws PayCommonException {
        PayCommonException payCommonException = new PayCommonException(message);
        payCommonException.getErrorMessage().setThirdLogNo(sequence);
        throw payCommonException;
    }

    public static void throwOperationFailedException(String message, CommonHeadResponse responseCode) throws PayCommonException {
        PayCommonException payCommonException = new PayCommonException(message);
        payCommonException.setErrorMessage(responseCode);
        throw payCommonException;
    }


}
